package ua.mykola.ds.tree.traversal;

import ua.mykola.ds.tree.Node;

public abstract class TreeTraversal {

	public void traverse(Node root) {
		preOrder(root);
		if (root.left != null) {
			traverse(root.left);
		}
		inOrder(root);
		if (root.right != null) {
			traverse(root.right);
		}
		postOrder(root);
	}

	protected void preOrder(Node root) {
	}

	protected void inOrder(Node root) {
	}

	protected void postOrder(Node root) {
	}

	protected abstract void process(Node node);
}
